clear all
set more off
use "/Users/yasenov/Desktop/replication package/master.dta"

************
************

encode major_code, gen(major_v)

local controls male age native_eth prescore
local cluster cluster(student_id_group)

eststo clear
eststo: reghdfe receiveZero starttime, absorb(classroom_group) `cluster'
eststo: reghdfe receiveZero starttime `controls', absorb(classroom_group major_v) `cluster'
eststo: reghdfe receiveZero starttime, absorb(classroom_group student_id_group) `cluster'
eststo: reghdfe grade starttime, absorb(classroom_group) `cluster'
eststo: reghdfe grade starttime `controls', absorb(classroom_group major_v) `cluster'
eststo: reghdfe grade starttime, absorb(classroom_group student_id_group) `cluster'
eststo: reghdfe zGradeConditional starttime, absorb(classroom_group) `cluster'
eststo: reghdfe zGradeConditional starttime `controls', absorb(classroom_group major_v) `cluster'
eststo: reghdfe zGradeConditional starttime, absorb(classroom_group student_id_group) `cluster'

la var starttime "\ \ \ Start Time"
la var SDstarttime "\ \ \ $ \sigma $(Start Time)"

quietly esttab using "StartTime.tex", ///
    replace se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes keep(starttime) ///
	refcat(starttime "\underline{Panel A: Start Time}", nolabel) noconstant nogaps ///
	mgroups("Received zero" "Raw grade [1,10]" "Standardized grade", pattern(1 0 0 1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  ///
    mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)") label postfoot("")

************
************

local controls male age native_eth prescore student_fatigue

eststo clear
eststo: reghdfe receiveZero SDstarttime, absorb(classroom_group) `cluster'
eststo: reghdfe receiveZero SDstarttime `controls', absorb(classroom_group major_v) `cluster'
eststo: reghdfe receiveZero SDstarttime, absorb(classroom_group student_id_group) `cluster'
eststo: reghdfe grade SDstarttime, absorb(classroom_group) `cluster'
eststo: reghdfe grade SDstarttime `controls', absorb(classroom_group major_v) `cluster'
eststo: reghdfe grade SDstarttime, absorb(classroom_group student_id_group) `cluster'
eststo: reghdfe zGradeConditional SDstarttime, absorb(classroom_group) `cluster'
eststo: reghdfe zGradeConditional SDstarttime `controls', absorb(classroom_group major_v) `cluster'
eststo: reghdfe zGradeConditional SDstarttime, absorb(classroom_group student_id_group) `cluster'

la var starttime "\ \ \ Start Time"
la var SDstarttime "\ \ \ $ \sigma $(Start Time)"

quietly esttab using "StartTime.tex", ///
    append se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes keep(SDstarttime) ///
	refcat(SDstarttime "\underline{Panel B: Schedule Irregularity 1}", nolabel) noconstant nogaps ///
   mtitles("" "" "" "" "" "" "" "" "") label postfoot("") prehead("") 

************
************
   
eststo clear
eststo: reghdfe receiveZero IQRstarttime, absorb(classroom_group) `cluster'
estadd local classroomFE "X"
estadd local studentFE " "
estadd local controls " "
eststo: reghdfe receiveZero IQRstarttime `controls', absorb(classroom_group major_v) `cluster'
estadd local classroomFE "X"
estadd local studentFE " "
estadd local controls "X"
eststo: reghdfe receiveZero IQRstarttime, absorb(classroom_group student_id_group) `cluster'
estadd local classroomFE "X"
estadd local studentFE "X"
estadd local controls " "
eststo: reghdfe grade IQRstarttime, absorb(classroom_group) `cluster'
estadd local classroomFE "X"
estadd local studentFE " "
estadd local controls " "
eststo: reghdfe grade IQRstarttime `controls', absorb(classroom_group major_v) `cluster'
estadd local classroomFE "X"
estadd local studentFE " "
estadd local controls "X"
eststo: reghdfe grade IQRstarttime, absorb(classroom_group student_id_group) `cluster'
estadd local classroomFE "X"
estadd local studentFE "X"
estadd local controls " "
eststo: reghdfe zGradeConditional IQRstarttime, absorb(classroom_group) `cluster'
estadd local classroomFE "X"
estadd local studentFE " "
estadd local controls " "
eststo: reghdfe zGradeConditional IQRstarttime `controls', absorb(classroom_group major_v) `cluster'
estadd local classroomFE "X"
estadd local studentFE " "
estadd local controls "X"
eststo: reghdfe zGradeConditional IQRstarttime, absorb(classroom_group student_id_group) `cluster'
estadd local classroomFE "X"
estadd local studentFE "X"
estadd local controls " "

la var starttime "\ \ \ Start Time"
la var SDstarttime "\ \ \ $ \sigma $(Start Time)"
la var IQRstarttime "\ \ \ IQR(Start Time)"

quietly esttab using "StartTime.tex", ///
	append se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes keep(IQRstarttime) ///
	refcat(IQRstarttime "\underline{Panel C: Schedule Irregularity 2}", nolabel) noconstant nogaps ///
	scalars("classroomFE Classroom FE" "controls Student controls" "studentFE Student FE") ///
   mtitles("" "" "" "" "" "" "" "" "") label prehead("") 
